# _*_ coding: utf-8 _*_
# @Author   : Wei Yue
# @Time     : 2024-09-04 14:02
# @Function :
from automotiveNews.crawler.auto_home import AutomotiveHomeCrawler
from automotiveNews.crawler.my_doucument import MyDocument
from automotiveNews.crawler.yi_che import YiCheCrawler
from automotiveNews.crawler.che_zhi import CheZhiCrawler
from common.constant import DUE_DAYS, CarTopics, SEARCHWORDS, WANG_CAI_DLZC, WANG_CAI_DJYDK, XI_MO_DJQ, GAI_SHI_QCSQ, \
    WECHAT_PAGE,RIO,CHUANGWEI,JISHI
from crawler.china_economic_net import ChinaEconomicNetCrawler
from crawler.dong_che_di import DongCheDiSelenium
from crawler.ne_time import NETimeCrawler
from crawler.pacific_auto import PacificAutoCrawler
from crawler.wechat_public import WechatPublicCrawler

if __name__ == '__main__':
    articles = []
    # 开始汽车之家爬虫 (零部件板块)
    automotiveCrawler = AutomotiveHomeCrawler('https://www.autohome.com.cn/hangye/news/5', DUE_DAYS, CarTopics.OEM)
    automotiveCrawler.startCrawl(articles)
    # 开始汽车之家爬虫 (行业政策板块)
    automotiveCrawler = AutomotiveHomeCrawler('https://www.autohome.com.cn/hangye/news/9', DUE_DAYS,
                                              CarTopics.POLICY_ANALYSIS)
    automotiveCrawler.startCrawl(articles)
    # 开始易车爬虫
    yiche = YiCheCrawler('https://news.yiche.com/jishu/', DUE_DAYS, topic=CarTopics.FRONTIER_TECH)
    yiche.startCrawl(articles)
    # 开始车质网爬虫
    chezhi = CheZhiCrawler('https://www.12365auto.com/parts/index.shtml', DUE_DAYS, topic=CarTopics.OEM)
    chezhi.startCrawl(articles)
    # 开始太平洋汽车爬虫
    pacificAuto = PacificAutoCrawler('http://www.pcauto.com.cn/tech/kuaixun/', DUE_DAYS, topic=CarTopics.FRONTIER_TECH)
    pacificAuto.startCrawl(articles)
    # 开始中国经济网爬虫
    china_economic_net = ChinaEconomicNetCrawler('http://intl.ce.cn', DUE_DAYS, CarTopics.INTERNATIONAL_VIEW)
    china_economic_net.startCrawlInternationalNews(articles)
    china_economic_net.startCrawlInternationalEconomy(articles)
    # NE时代网资讯爬虫
    ne_time = NETimeCrawler('https://ne-time.cn/web/article', DUE_DAYS)
    ne_time.startCrawlInformation(articles, CarTopics.MARKET_INFO)
    # 2代表电驱动板块，103代表半导体板块,4代表政策法规板块,19代表整车OEM板块
    ne_time.startCrawlOtherSection(articles, 2, CarTopics.ELECTRIC_DRIVE)
    ne_time.startCrawlOtherSection(articles, 103, CarTopics.FRONTIER_TECH)
    ne_time.startCrawlOtherSection(articles, 4, CarTopics.POLICY_ANALYSIS)
    ne_time.startCrawlOtherSection(articles, 19, CarTopics.OEM)
    # 开始懂车帝爬虫
    dongchedi = DongCheDiSelenium('https://www.dongchedi.com', DUE_DAYS, SEARCHWORDS)
    dongchedi.startCrawl(articles)
    # 开始微信公众号爬虫
    wechat_public_crawler = WechatPublicCrawler('https://mp.weixin.qq.com/cgi-bin/appmsg', DUE_DAYS,
                                                CarTopics.WECHAT_PUBLIC)
    # 爬取旺材动力总成
    wechat_public_crawler.startCrawlWithPublicName(WECHAT_PAGE, articles, WANG_CAI_DLZC)
    # 爬取旺材电机与电控
    wechat_public_crawler.startCrawlWithPublicName(WECHAT_PAGE, articles, WANG_CAI_DJYDK)
    # 爬取西莫电机圈
    wechat_public_crawler.startCrawlWithPublicName(WECHAT_PAGE, articles, XI_MO_DJQ)
    # 爬取盖世汽车社区
    wechat_public_crawler.startCrawlWithPublicName(WECHAT_PAGE, articles, GAI_SHI_QCSQ)
    wechat_public_crawler.startCrawlWithPublicName(WECHAT_PAGE, articles, RIO)
    wechat_public_crawler.startCrawlWithPublicName(WECHAT_PAGE, articles, CHUANGWEI)
    wechat_public_crawler.startCrawlWithPublicName(WECHAT_PAGE, articles, JISHI)
    # article去重
    articles = list(set(articles))
    # 输出到word文档
    myDoc = MyDocument(articles)
    myDoc.generate_docs()